
TARGET = ls1c300b_hrst_ninjia

BUILD_DIR = $(OUT_DIR_PATH)

# 虚拟机里的交叉编译工具链
#CROSS_COMPILE 	=mips-mti-elf-
#COPY   = cp
# windows下的交叉编译工具链
CROSS_COMPILE 	=mips-mti-elf-
COPY    = copy

#
# Include the make variables (CC, etc...)
#

AS		= $(CROSS_COMPILE)as
LD		= $(CROSS_COMPILE)ld
CC		= $(CROSS_COMPILE)-gcc
CPP		= $(CC) -E
AR		= $(CROSS_COMPILE)ar
NM		= $(CROSS_COMPILE)nm
STRIP		= $(CROSS_COMPILE)strip
OBJCOPY		= $(CROSS_COMPILE)objcopy
OBJDUMP		= $(CROSS_COMPILE)objdump
SIZE		= $(CROSS_COMPILE)size



STATIC_LIB = -lmytest -lpm -lstartup_ls1c300b -lloogsonsdk -lcpup -lexchook -lsec_static -lutils -larch -lkernel -lutils -larch -lsec_static -lkernel -lmusl-c
#STATIC_LIB = 
STATIC_LIB_DIR = -L$(BUILD_DIR)/libs

#头文件查找路径
INCLUDES = -Iinclude -Ilib -Iexample -Iapp
#libc的头文件所在目录
VPATH += include
#链接库查找路径
LIBS = 

#编译参数
DEVFLAGS = -mips32 -EL
CCFLAGS = $(DEVFLAGS) -mno-abicalls -fno-pic -g -Wall -Wstrict-prototypes -Wno-uninitialized -Wno-format -Wno-main -O2 -G 0 -fno-builtin -fgnu89-inline
AFLAGS  = $(DEVFLAGS) -mno-abicalls -fno-pic -G4 0 -Wall -mno-abicalls -fno-builtin  -D__ASSEMBLY__
#链接参数
LDFLAGS = $(DEVFLAGS) -G 0 -n -N 

# 最终的目标文件
OUTPUT_ELF = $(BUILD_DIR)/$(TARGET).elf
OUTPUT_DEBUG_ELF = OpenLoongsonLib1c_debug.elf
OUTPUT_BIN = $(BUILD_DIR)/$(TARGET).bin
OUTPUT_MAP = $(BUILD_DIR)/$(TARGET).map

all:$(OUTPUT_BIN)
$(OUTPUT_BIN):$(OBJS)
	$(LD) $(STATIC_LIB_DIR) $(LDFLAGS)  -T ld.script $(STATIC_LIB) -e start -o $(OUTPUT_ELF) $^ -Map $(BUILD_DIR)/$(TARGET).map $(STATIC_LIB)
	$(STRIP) -g -S --strip-debug $(OUTPUT_ELF)
	$(OBJCOPY) -O binary $(OUTPUT_ELF) $(OUTPUT_BIN)
	$(SIZE) $(OUTPUT_ELF)


	
	
clean:
	rm -f $(OBJS) $(OUTPUT_ELF) $(OUTPUT_BIN) $(OUTPUT_MAP)
	
	
